package com.example.cms.service.impl;

import com.example.cms.entity.User;
import com.example.cms.mapper.UserDao;
import com.example.cms.service.UserService;
import com.example.cms.utils.Maps;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceimpl implements UserService {

    @Autowired
    private UserDao userDao;

    @Override
    public int create(User user) {
        return userDao.create(user);
    }

    @Override
    public int delete(Integer id) {
       return userDao.delete(Maps.build( id).getMap());
    }

    @Override
    public int update(User user){
        return userDao.update(Maps.build(user.getId()).beanToMapForUpdate(user));
    }

    @Override
    public List<User> query(User user){
        return userDao.query(Maps.build().beanToMap(user));
    }

    @Override
    public User detail(Integer id){
        return userDao.detail(Maps.build(id).getMap());
    }

    @Override
    public int count(User user){
        return userDao.count(Maps.build().beanToMap(user));
    }

}
